Skip to content

internal: define package variables for paths#20060

Open
tacerus wants to merge 1 commit intogoauthentik:mainfrom
tacerus:gounicorn-vars
Open

internal: define package variables for paths#20060
tacerus wants to merge 1 commit intogoauthentik:mainfrom
tacerus:gounicorn-vars

Conversation

@tacerus
Copy link

@tacerus tacerus commented Feb 5, 2026

Details

During distribution packaging, files are typically installed in standardized paths (for example, adhering to the FHS). Avoid the need for patching the source code to facilitate this by allowing the paths needed by the server to be overwritten at build time.

The defaults are kept as they are to not affect existing behavior.

Example usage (simplified):

$ go build \
  -ldflags '-X "goauthentik.io/internal/gounicorn.manageCmd=/usr/bin/ak-manage" -X "goauthentik.io/internal/gounicorn.gunicornCmd=/usr/bin/gunicorn" -X "goauthentik.io/internal/gounicorn.gunicornConf=/etc/authentik/gunicorn.conf.py" -X "goauthentik.io/internal/gounicorn.pidDir=/run/authentik" -X "goauthentik.io/web.staticDir=/usr/share/authentik/web/dist"' ./cmd/server

Ideally, similar functionality would also exist for the various path references in the Python code. However, those require further consideration as there is no equivalent concept of build time options like there is in Go.


Checklist

  • Local tests pass (ak test authentik/)
  • The code has been formatted (make lint-fix)

If an API change has been made

  • The API schema has been updated (make gen-build)

If changes to the frontend have been made

  • The code has been formatted (make web)

If applicable

  • The documentation has been updated
  • The documentation has been formatted (make docs)

During distribution packaging, files are typically installed in
standardized paths (for example, adhering to the FHS).
Avoid the need for patching the source code to facilitate this by
allowing the paths needed by the server to be overwritten at build time.

The defaults are kept as they are to not affect existing behavior.

Example usage (simplified):
$ go build \
  -ldflags '-X "goauthentik.io/internal/gounicorn.manageCmd=/usr/bin/ak-manage" -X "goauthentik.io/internal/gounicorn.gunicornCmd=/usr/bin/gunicorn" -X "goauthentik.io/internal/gounicorn.gunicornConf=/etc/authentik/gunicorn.conf.py" -X "goauthentik.io/internal/gounicorn.pidDir=/run/authentik" -X "goauthentik.io/web.staticDir=/usr/share/authentik/web/dist"' ./cmd/server

Ideally, similar functionality would also exist for the various path
references in the Python code. However, those require further
consideration as there is no equivalent concept of build time options
like there is in Go.

Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
@tacerus tacerus requested review from a team as code owners February 5, 2026 17:31
@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit ff775db
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6984d3f39d04520008e07ebc
😎 Deploy Preview https://deploy-preview-20060--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for authentik-storybook ready!

Name Link
🔨 Latest commit ff775db
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6984d3f35ecf5f0008b28ff2
😎 Deploy Preview https://deploy-preview-20060--authentik-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link

netlify bot commented Feb 5, 2026

Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit ff775db
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6984d3f30fb5df00086dc9ac
😎 Deploy Preview https://deploy-preview-20060--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.19%. Comparing base (c04c7ab) to head (ff775db).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #20060      +/-   ##
==========================================
- Coverage   93.25%   93.19%   -0.07%     
==========================================
  Files         968      968              
  Lines       53438    53438              
==========================================
- Hits        49836    49802      -34     
- Misses       3602     3636      +34     
Flag Coverage Δ
conformance 38.05% <ø> (+<0.01%) ⬆️
e2e 44.04% <ø> (+<0.01%) ⬆️
integration 22.71% <ø> (-0.05%) ⬇️
unit 91.41% <ø> (+<0.01%) ⬆️
unit-migrate 91.42% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@BeryJu BeryJu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good for the most part; if you dont mind me asking what's the idea behind adjusting these paths?


func (g *GoUnicorn) initCmd() {
command := "./manage.py"
command := manageCmd
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this is required for this, since manage.py is only used during development where you're probably running go run ./cmd/server

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer, I didn't realize it was overwritten after !config.Get().Debug. I think it might still be useful though if trying to debug against the system Python environment?

args := []string{"dev_server"}
if !config.Get().Debug {
pidFile, err := os.CreateTemp("", "authentik-gunicorn.*.pid")
pidFile, err := os.CreateTemp(pidDir, "authentik-gunicorn.*.pid")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might not be needed since that'll just use TMP by default

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was actually the reason, because I try to avoid storing files in world-writable directories. Indeed it could be set using TMPDIR, but it's not ideal because it would still default to /tmp on most systems if not set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants